const express = require('express');
const router = express.Router();
const {
  getAllCategories,
  getCategoryById,
  createCategory,
  updateCategory,
  deleteCategory
} = require('../controllers/categoryController');
const { authenticate } = require('../middleware/auth');

// 所有分类路由都需要认证
router.use(authenticate);

// 获取分类列表
router.get('/', getAllCategories);

// 获取单个分类详情
router.get('/:id', getCategoryById);

// 创建分类
router.post('/', createCategory);

// 更新分类
router.put('/:id', updateCategory);

// 删除分类
router.delete('/:id', deleteCategory);

module.exports = router;

